package tv.danmaku.ijk.media.player;

import android.os.Bundle;
import android.text.TextUtils;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Locale;

public class IjkMediaMeta {
    public static class IjkStreamMeta {
        public long mBitrate;
        public long mChannelLayout;
        public String mCodecLongName;
        public String mCodecName;
        public String mCodecProfile;
        public int mFpsDen;
        public int mFpsNum;
        public int mHeight;
        public final int mIndex;
        public String mLanguage;
        public Bundle mMeta;
        public int mSampleRate;
        public int mSarDen;
        public int mSarNum;
        public int mTbrDen;
        public int mTbrNum;
        public String mType;
        public int mWidth;

        public IjkStreamMeta(int arg1) {
            this.mIndex = arg1;
        }

        public String getBitrateInline() {
            String v0;
            long v8 = 1000;
            if(this.mBitrate <= 0) {
                v0 = "N/A";
            }
            else if(this.mBitrate < v8) {
                v0 = String.format(Locale.US, "%d bit/s", Long.valueOf(this.mBitrate));
            }
            else {
                v0 = String.format(Locale.US, "%d kb/s", Long.valueOf(this.mBitrate / v8));
            }

            return v0;
        }

        public String getChannelLayoutInline() {
            String v0;
            if(this.mChannelLayout <= 0) {
                v0 = "N/A";
            }
            else if(this.mChannelLayout == 4) {
                v0 = "mono";
            }
            else if(this.mChannelLayout == 3) {
                v0 = "stereo";
            }
            else {
                v0 = String.format(Locale.US, "%x", Long.valueOf(this.mChannelLayout));
            }

            return v0;
        }

        public String getCodecLongNameInline() {
            String v0;
            if(!TextUtils.isEmpty(this.mCodecLongName)) {
                v0 = this.mCodecLongName;
            }
            else if(!TextUtils.isEmpty(this.mCodecName)) {
                v0 = this.mCodecName;
            }
            else {
                v0 = "N/A";
            }

            return v0;
        }

        public String getCodecShortNameInline() {
            String v0 = !TextUtils.isEmpty(this.mCodecName) ? this.mCodecName : "N/A";
            return v0;
        }

        public String getFpsInline() {
            String v0 = this.mFpsNum <= 0 || this.mFpsDen <= 0 ? "N/A" : String.valueOf((((float)this.mFpsNum)) / (((float)this.mFpsDen)));
            return v0;
        }

        public int getInt(String arg2) {
            return this.getInt(arg2, 0);
        }

        public int getInt(String arg3, int arg4) {
            String v0 = this.getString(arg3);
            if(!TextUtils.isEmpty(((CharSequence)v0))) {
                try {
                    arg4 = Integer.parseInt(v0);
                }
                catch(NumberFormatException v0_1) {
                }
            }

            return arg4;
        }

        public long getLong(String arg3) {
            return this.getLong(arg3, 0);
        }

        public long getLong(String arg3, long arg4) {
            String v0 = this.getString(arg3);
            if(!TextUtils.isEmpty(((CharSequence)v0))) {
                try {
                    arg4 = Long.parseLong(v0);
                }
                catch(NumberFormatException v0_1) {
                }
            }

            return arg4;
        }

        public String getResolutionInline() {
            String v0_1;
            Locale v0;
            int v6 = 2;
            if(this.mWidth <= 0 || this.mHeight <= 0) {
                v0_1 = "N/A";
            }
            else {
                if(this.mSarNum > 0 && this.mSarDen > 0) {
                    v0 = Locale.US;
                    Object[] v2 = new Object[4];
                    v2[0] = Integer.valueOf(this.mWidth);
                    v2[1] = Integer.valueOf(this.mHeight);
                    v2[v6] = Integer.valueOf(this.mSarNum);
                    v2[3] = Integer.valueOf(this.mSarDen);
                    v0_1 = String.format(v0, "%d x %d [SAR %d:%d]", v2);
                    return v0_1;
                }

                v0 = Locale.US;
                v0_1 = String.format(v0, "%d x %d", Integer.valueOf(this.mWidth), Integer.valueOf(this.mHeight));
            }

            return v0_1;
        }

        public String getSampleRateInline() {
            String v0 = this.mSampleRate <= 0 ? "N/A" : String.format(Locale.US, "%d Hz", Integer.valueOf(this.mSampleRate));
            return v0;
        }

        public String getString(String arg2) {
            return this.mMeta.getString(arg2);
        }
    }

    public static final long AV_CH_BACK_CENTER = 256;
    public static final long AV_CH_BACK_LEFT = 16;
    public static final long AV_CH_BACK_RIGHT = 32;
    public static final long AV_CH_FRONT_CENTER = 4;
    public static final long AV_CH_FRONT_LEFT = 1;
    public static final long AV_CH_FRONT_LEFT_OF_CENTER = 64;
    public static final long AV_CH_FRONT_RIGHT = 2;
    public static final long AV_CH_FRONT_RIGHT_OF_CENTER = 128;
    public static final long AV_CH_LAYOUT_2POINT1 = 11;
    public static final long AV_CH_LAYOUT_2_1 = 259;
    public static final long AV_CH_LAYOUT_2_2 = 1539;
    public static final long AV_CH_LAYOUT_3POINT1 = 15;
    public static final long AV_CH_LAYOUT_4POINT0 = 263;
    public static final long AV_CH_LAYOUT_4POINT1 = 271;
    public static final long AV_CH_LAYOUT_5POINT0 = 1543;
    public static final long AV_CH_LAYOUT_5POINT0_BACK = 55;
    public static final long AV_CH_LAYOUT_5POINT1 = 1551;
    public static final long AV_CH_LAYOUT_5POINT1_BACK = 63;
    public static final long AV_CH_LAYOUT_6POINT0 = 1799;
    public static final long AV_CH_LAYOUT_6POINT0_FRONT = 1731;
    public static final long AV_CH_LAYOUT_6POINT1 = 1807;
    public static final long AV_CH_LAYOUT_6POINT1_BACK = 319;
    public static final long AV_CH_LAYOUT_6POINT1_FRONT = 1739;
    public static final long AV_CH_LAYOUT_7POINT0 = 1591;
    public static final long AV_CH_LAYOUT_7POINT0_FRONT = 1735;
    public static final long AV_CH_LAYOUT_7POINT1 = 1599;
    public static final long AV_CH_LAYOUT_7POINT1_WIDE = 1743;
    public static final long AV_CH_LAYOUT_7POINT1_WIDE_BACK = 255;
    public static final long AV_CH_LAYOUT_HEXAGONAL = 311;
    public static final long AV_CH_LAYOUT_MONO = 4;
    public static final long AV_CH_LAYOUT_OCTAGONAL = 1847;
    public static final long AV_CH_LAYOUT_QUAD = 51;
    public static final long AV_CH_LAYOUT_STEREO = 3;
    public static final long AV_CH_LAYOUT_STEREO_DOWNMIX = 1610612736;
    public static final long AV_CH_LAYOUT_SURROUND = 7;
    public static final long AV_CH_LOW_FREQUENCY = 8;
    public static final long AV_CH_LOW_FREQUENCY_2 = 34359738368L;
    public static final long AV_CH_SIDE_LEFT = 512;
    public static final long AV_CH_SIDE_RIGHT = 1024;
    public static final long AV_CH_STEREO_LEFT = 536870912;
    public static final long AV_CH_STEREO_RIGHT = 1073741824;
    public static final long AV_CH_SURROUND_DIRECT_LEFT = 8589934592L;
    public static final long AV_CH_SURROUND_DIRECT_RIGHT = 17179869184L;
    public static final long AV_CH_TOP_BACK_CENTER = 65536;
    public static final long AV_CH_TOP_BACK_LEFT = 32768;
    public static final long AV_CH_TOP_BACK_RIGHT = 131072;
    public static final long AV_CH_TOP_CENTER = 2048;
    public static final long AV_CH_TOP_FRONT_CENTER = 8192;
    public static final long AV_CH_TOP_FRONT_LEFT = 4096;
    public static final long AV_CH_TOP_FRONT_RIGHT = 16384;
    public static final long AV_CH_WIDE_LEFT = 2147483648L;
    public static final long AV_CH_WIDE_RIGHT = 4294967296L;
    public static final String IJKM_KEY_AUDIO_STREAM = "audio";
    public static final String IJKM_KEY_BITRATE = "bitrate";
    public static final String IJKM_KEY_CHANNEL_LAYOUT = "channel_layout";
    public static final String IJKM_KEY_CODEC_LEVEL = "codec_level";
    public static final String IJKM_KEY_CODEC_LONG_NAME = "codec_long_name";
    public static final String IJKM_KEY_CODEC_NAME = "codec_name";
    public static final String IJKM_KEY_CODEC_PIXEL_FORMAT = "codec_pixel_format";
    public static final String IJKM_KEY_CODEC_PROFILE = "codec_profile";
    public static final String IJKM_KEY_DURATION_US = "duration_us";
    public static final String IJKM_KEY_FORMAT = "format";
    public static final String IJKM_KEY_FPS_DEN = "fps_den";
    public static final String IJKM_KEY_FPS_NUM = "fps_num";
    public static final String IJKM_KEY_HEIGHT = "height";
    public static final String IJKM_KEY_LANGUAGE = "language";
    public static final String IJKM_KEY_SAMPLE_RATE = "sample_rate";
    public static final String IJKM_KEY_SAR_DEN = "sar_den";
    public static final String IJKM_KEY_SAR_NUM = "sar_num";
    public static final String IJKM_KEY_START_US = "start_us";
    public static final String IJKM_KEY_STREAMS = "streams";
    public static final String IJKM_KEY_TBR_DEN = "tbr_den";
    public static final String IJKM_KEY_TBR_NUM = "tbr_num";
    public static final String IJKM_KEY_TYPE = "type";
    public static final String IJKM_KEY_VIDEO_STREAM = "video";
    public static final String IJKM_KEY_WIDTH = "width";
    public static final String IJKM_VAL_TYPE__AUDIO = "audio";
    public static final String IJKM_VAL_TYPE__UNKNOWN = "unknown";
    public static final String IJKM_VAL_TYPE__VIDEO = "video";
    public IjkStreamMeta mAudioStream;
    public long mBitrate;
    public long mDurationUS;
    public String mFormat;
    public Bundle mMediaMeta;
    public long mStartUS;
    public final ArrayList mStreams;
    public IjkStreamMeta mVideoStream;

    public IjkMediaMeta() {

        this.mStreams = new ArrayList();
    }

    public String getDurationInline() {
        long v0 = (this.mDurationUS + 5000) / 1000000;
        long v2 = v0 / 60;
        return String.format(Locale.US, "%02d:%02d:%02d", Long.valueOf(v2 / 60), Long.valueOf(v2 % 60), Long.valueOf(v0 % 60));
    }

    public int getInt(String arg3, int arg4) {
        String v0 = this.getString(arg3);
        if(!TextUtils.isEmpty(((CharSequence)v0))) {
            try {
                arg4 = Integer.parseInt(v0);
            }
            catch(NumberFormatException v0_1) {
            }
        }

        return arg4;
    }

    public int getInt(String arg2) {
        return this.getInt(arg2, 0);
    }

    public long getLong(String arg3) {
        return this.getLong(arg3, 0);
    }

    public long getLong(String arg3, long arg4) {
        String v0 = this.getString(arg3);
        if(!TextUtils.isEmpty(((CharSequence)v0))) {
            try {
                arg4 = Long.parseLong(v0);
            }
            catch(NumberFormatException v0_1) {
            }
        }

        return arg4;
    }

    public ArrayList getParcelableArrayList(String arg2) {
        return this.mMediaMeta.getParcelableArrayList(arg2);
    }

    public String getString(String arg2) {
        return this.mMediaMeta.getString(arg2);
    }

    public static IjkMediaMeta parse(Bundle arg10) {
        IjkMediaMeta v0_1;
        int v0 = -1;
        if(arg10 == null) {
            v0_1 = null;
        }
        else {
            IjkMediaMeta v2 = new IjkMediaMeta();
            v2.mMediaMeta = arg10;
            v2.mFormat = v2.getString("format");
            v2.mDurationUS = v2.getLong("duration_us");
            v2.mStartUS = v2.getLong("start_us");
            v2.mBitrate = v2.getLong("bitrate");
            int v3 = v2.getInt("video", v0);
            int v4 = v2.getInt("audio", v0);
            ArrayList v1 = v2.getParcelableArrayList("streams");
            if(v1 == null) {
                v0_1 = v2;
            }
            else {
                Iterator v5 = v1.iterator();
                int v1_1 = v0;
                while(v5.hasNext()) {
                    Object v0_2 = v5.next();
                    ++v1_1;
                    if(v0_2 == null) {
                        continue;
                    }

                    IjkStreamMeta v6 = new IjkStreamMeta(v1_1);
                    v6.mMeta = ((Bundle)v0_2);
                    v6.mType = v6.getString("type");
                    v6.mLanguage = v6.getString("language");
                    if(TextUtils.isEmpty(v6.mType)) {
                        continue;
                    }

                    v6.mCodecName = v6.getString("codec_name");
                    v6.mCodecProfile = v6.getString("codec_profile");
                    v6.mCodecLongName = v6.getString("codec_long_name");
                    v6.mBitrate = ((long)v6.getInt("bitrate"));
                    if(v6.mType.equalsIgnoreCase("video")) {
                        v6.mWidth = v6.getInt("width");
                        v6.mHeight = v6.getInt("height");
                        v6.mFpsNum = v6.getInt("fps_num");
                        v6.mFpsDen = v6.getInt("fps_den");
                        v6.mTbrNum = v6.getInt("tbr_num");
                        v6.mTbrDen = v6.getInt("tbr_den");
                        v6.mSarNum = v6.getInt("sar_num");
                        v6.mSarDen = v6.getInt("sar_den");
                        if(v3 == v1_1) {
                            v2.mVideoStream = v6;
                        }
                    }
                    else if(v6.mType.equalsIgnoreCase("audio")) {
                        v6.mSampleRate = v6.getInt("sample_rate");
                        v6.mChannelLayout = v6.getLong("channel_layout");
                        if(v4 == v1_1) {
                            v2.mAudioStream = v6;
                        }
                    }

                    v2.mStreams.add(v6);
                }

                v0_1 = v2;
            }
        }

        return v0_1;
    }
}

